package com.uairobot.bill.freeswitch.util;

import org.freeswitch.esl.client.inbound.Client;
import org.freeswitch.esl.client.inbound.InboundConnectionFailure;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class FsUtil {
  private static String fsIp = "47.92.52.211";
  private static int fsPort = 8021;
  private static String fsPswd = "ClueCon";

  public static Client connectThis() {
    // 连接freeswitch
    Client client = connect(fsIp, fsPort, fsPswd);
    return client;
  }

  public static Client connect(String fsIp, int fsPort, String fsPswd) {
    Client client = new Client();
    // 连接freeswitch
    try {
      client.connect(fsIp, fsPort, fsPswd, 10);
    } catch (InboundConnectionFailure e) {
      log.error("连接freeswitch失败:ip:{},port:{}", fsIp, fsPort);
      e.printStackTrace();
    }
    return client;
  }
}